<template>
  <div>
    <el-dialog title="用户" :visible.sync="dialogVisible" width="30%">
      <el-form ref="form" :model="form" label-width="120px" :rules="rules">

        <el-form-item label="昵称" prop="nickName">
          <el-input v-model="form.nickName" />
        </el-form-item>
        <el-form-item label="手机号" prop="mobile">
          <el-input v-model="form.mobile" />
        </el-form-item>
        <el-form-item label="区号"  prop="countryNo">
          <el-input v-model="form.countryNo" />
        </el-form-item>
        
        <el-form-item>
          <el-button type="primary" @click="onSubmit">确定</el-button>
          <el-button @click="dialogVisible = false">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

  </div>
</template>
<script>
import { saveOrUpdate } from '@/api/table'

export default {

  data() {
    return {
      pn: 0,
      loadingState: false,
      dialogVisible: false,
      videoStatae: false,
      fileList: [],
      video: null,
      upLoadProgress: 0,
      form: {
        id: '',
        countryNo: '',

        mobile: '',
        nickName: '',
  
      },
      rules: {

        nickName: [
          { required: true, message: '请输入昵称', trigger: 'blur' }
        ],
        mobile: [
          { required: true, message: '请输入手机号', trigger: 'blur' }
        ],
       
        countryNo: [
          { required: true, message: '请输入区号', trigger: 'blur' }
        ]

      }
    }
  },

  methods: {

    onSubmit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          saveOrUpdate(this.form).then(res => {
            this.$parent.fetchData()
            this.dialogVisible = false
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    show() {
      this.resetForm()
      this.dialogVisible = true
    },
    edit(e) {
      this.form = {
        id: e.id,
        mobile: e.mobile,
        nickName: e.nickName,
        countryNo: e.countryNo
      }
      this.dialogVisible = true
    },
    resetForm() {
      this.form = {
        id: '',
        mobile: '',
        nickName: '',
        countryNo:''
      }
    }

  }
}
</script>
<style scoped lang="scss">
.loadingText {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: rgba($color: #000000, $alpha: 0.5);
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;

  p {
    color: #fff;
  }
}

.btn {
  outline: none;
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  text-align: center;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  outline: 0;
  -webkit-transition: 0.1s;
  transition: 0.1s;
  font-weight: 500;
  padding: 8px 15px;
  font-size: 12px;
  border-radius: 3px;
  color: #fff;
  background-color: #409eff;
  border-color: #409eff;
  margin-right: 10px;
}

.el-tag+.el-tag {
  margin-left: 10px;
}

.button-new-tag {
  margin-left: 10px;
  height: 32px;
  line-height: 30px;
  padding-top: 0;
  padding-bottom: 0;
}

.input-new-tag {
  width: 90px;
  margin-left: 10px;
  vertical-align: bottom;
}

.list {
  .item {
    border: 1px solid #c0ccda;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-top: 10px;

    >div {
      display: flex;

      img {
        margin-right: 15px;
      }
    }

    >i {
      font-size: 20px;
      cursor: pointer;
    }
  }
}
</style>
